home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_srgp.lha / srgp / examples / testmodifiers.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-09  |  1.8 KB  |  60 lines

  1. #include "srgp.h"
  2. #include <malloc.h>
  3. #include <stdio.h>
  4.  
  5. /* Only the left button is ever seen. */
  6. /* Any unmodified button press adds the new point to the polyline.
  7.    A SHIFT-modified button press sets a new anchor point.
  8.    A META-modified button press causes the application to exit.
  9.       (WARNING: your window manager MAY be swallowing all meta'ed events!)
  10.    A META-modified 'Z' also causes the application to exit.
  11.    */
  12.  
  13. main()
  14. {
  15.    deluxe_locator_measure locmeasure, pastlocmeasure;
  16.    deluxe_keyboard_measure keymeasure;
  17.    int whichdev;
  18.  
  19.    keymeasure.buffer = malloc(51);
  20.    keymeasure.buffer_length = 50;
  21.  
  22.    SRGP_begin ("Test of modifiers", 800,800,1,FALSE);
  23.  
  24.    SRGP_setLocatorEchoType(CURSOR);
  25.    SRGP_setLocatorButtonMask(LEFT_BUTTON_MASK);
  26.    pastlocmeasure.position = SRGP_defPoint(5,5);
  27.    SRGP_setLocatorMeasure(pastlocmeasure.position);
  28.    SRGP_setKeyboardProcessingMode (RAW);
  29.    SRGP_setInputMode(LOCATOR, EVENT);   
  30.    SRGP_setInputMode(KEYBOARD, EVENT);   
  31.    SRGP_setLocatorEchoRubberAnchor(pastlocmeasure.position);
  32.    SRGP_setLocatorEchoType (RUBBER_LINE);
  33.    SRGP_setLineStyle(DASHED);
  34.  
  35.    while (1) {
  36.       whichdev = SRGP_waitEvent(INDEFINITE);
  37.       switch (whichdev) {
  38.       case LOCATOR:
  39.      SRGP_getDeluxeLocator(&locmeasure);
  40.      if (locmeasure.button_chord[LEFT_BUTTON] == UP)
  41.         break;
  42.      if (locmeasure.modifier_chord[META] == DOWN)
  43.         exit(0);
  44.      SRGP_setLocatorEchoRubberAnchor(locmeasure.position);
  45.      if (locmeasure.modifier_chord[SHIFT] == UP)
  46.         SRGP_line(pastlocmeasure.position, locmeasure.position);
  47.      else
  48.         SRGP_beep();
  49.      pastlocmeasure = locmeasure;
  50.      break;
  51.       case KEYBOARD:
  52.      SRGP_getDeluxeKeyboard(&keymeasure);
  53.      if ((keymeasure.modifier_chord[META] == DOWN) && 
  54.          (keymeasure.buffer[0] == 'Z'))
  55.          exit(0);
  56.      break;
  57.       }
  58.    }
  59. }
  60.